package cn.script.domain;

/**
 * @author 周永波
 */
public class Point {

    private int x;

    private int y;

    public static Point point(int x, int y) {
        return new Point(x, y);
    }

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int x() {
        return this.x;
    }

    public void x(int x) {
        this.x = x;
    }

    public int y() {
        return this.y;
    }

    public void y(int y) {
        this.y = y;
    }

    public void offset(int x, int y) {
        this.x += x;
        this.y += y;
    }

    public void offset(Point offset) {
        if (offset == null) {
            return;
        }
        this.x += offset.x;
        this.y += offset.y;
    }

    public boolean isRg(Point nowPoint, int x, int y) {
        if (nowPoint == null) {
            return false;
        }
        if (this.x + x >= nowPoint.x && this.x - x <= nowPoint.x
                && this.y + y >= nowPoint.y && this.y - y <= nowPoint.y) {
            return true;
        }
        return false;
    }
}
